<?php
header("content-type:text/html;charset=utf-8");
$arrBase=scandir("../../../www");
$a=array_search(".", $arrBase);
$b=array_search('..', $arrBase);
unset($arrBase[$a]);
unset($arrBase[$b]);
unset($arrBase[2]);
unset($arrBase[3]);
unset($arrBase[4]);
unset($arrBase[5]);
unset($arrBase[6]);
$arrDir=$_POST['arrDir'];
$daya=date("Y-m-d",time()-24*3600);
$dayb=date("Y-m-d",time());
$day1=$_POST['daya'];
$day2=$_POST['dayb'];
//var_dump($arrDir,$day1,$day2);
$arrDel=array();
$arrChange=array();
$arrAdd=array();
function findChange($day1,$day2,$dirname){
	global $arrDel,$arrChange,$arrAdd;
	$arrInfo1=file("E:get_info/".$day1."/".$dirname.".txt");
	$arrInfo2=file("E:get_info/".$day2."/".$dirname.".txt");
	foreach($arrInfo1 as $v){
		$arr=explode(";", $v);
		$arrIn1[$arr[0]]=$arr[1];
	}
	$arrInK1=array_keys($arrIn1);
	foreach($arrInfo2 as $v){
		$arr=explode(";", $v);
		$arrIn2[$arr[0]]=$arr[1];
	}
	$arrInK2=array_keys($arrIn2);
	foreach($arrInK1 as $v){
		$num1=trim($arrIn1[$v]);
		$num2=trim($arrIn2[$v]);
		if($arrIn2[$v]===null){
			$arrDel[]= $v." ---".$day1."中有，".$day2."中无";
		}
		if(!empty($num1) && !empty($num2) && $num1 != $num2){
			$arrChange[]= $v." ---大小有变动：".$day1."=>".$num1." -- ".$day2."=>".$num2;
		}
	}
	foreach($arrInK2 as $v){
		if($arrIn1[$v]===null){
			$arrAdd[]= $v." ---".$day1."中无，".$day2."有";
		}
	}
}
if($arrDir!=null){
	foreach($arrDir as $v){
		$row++;
		findChange($day1,$day2,$v);
		echo $row."、**************************************".$v."站点********************************************<br>";
		echo "<pre>";
		echo "被更改的：";
		print_r($arrChange);
		echo "被删除的：";
		print_r($arrDel);
		echo "有新增的：";
		print_r($arrAdd);
		echo "</pre>";
		$arrDel=array();
		$arrChange=array();
		$arrAdd=array();
	}
}
?>
<html>
	<head>
		<title>find_change</title>
	</head>
	<body>
		<div style="width: 60%; margin: 50px auto;">
		<form action="#" method="post">
			全选/全不选<input type="checkbox" checked="checked" id="all" onclick="ma()" /> <br>
<?php
	foreach($arrBase as $v){		
			echo $v.' <input type="checkbox" checked="checked" name="arrDir[]" value="'.$v.'" /><br />';
	}
?>				
			比对基准：<input type="text" name="daya" value="<?php echo $daya;?>" /><br />
			比对目标：<input type="text" name="dayb" value="<?php echo $dayb;?>" />
			<input type="submit" value="提交"/>
		</form>
		</div>
	</body>
	<script type="text/javascript">
		function ma(){
			var a=document.getElementsByName('arrDir[]');
			for(var i=0;i<a.length;i++){
				a[i].checked=all.checked;
			}
		}
	</script>
</html>


